<?php
namespace app\api\validate;

use think\Validate;

class OrderCreate extends Validate
{
    protected $rule = [
        'mchMerchantNo'  => 'require|regex: /^\d{6,10}$/',
        'mchOrderAmount' => 'require|float|gt:0|regex:/^\d+(\.\d{1,2})?$/',
        'userIp'      => 'require|ip',
    ];

    protected $message = [
        'mchMerchantNo.require'     => '商户号不能为空',
        'mchMerchantNo.regex'       => '商户号格式错误（6-10位数字）',
        'mchOrderAmount.require'    => '订单金额不能为空',
        'mchOrderAmount.float'      => '订单金额必须为数字',
        'mchOrderAmount.gt'         => '订单金额必须大于0',
        'mchOrderAmount.regex'      => '订单金额最多保留2位小数',
        'userIp.require'         => '用户IP不能为空',
        'userIp.ip'              => '用户IP格式错误',
    ];
}